import axios from 'axios'

let packageConfig = {
  method: 'post',
  url: `https://67dcfd0c-c143-49dd-81a6-3d6aabd6ef7b.bspapp.com/com-power`,
  data: {}
}
const _axios = axios.create()

_axios.interceptors.request.use(
    function (config) {
      let {method, url, params,headers,data,body,responseType,withCredentials,form,forms} = config
      responseType=responseType?responseType:''
      packageConfig.data = {method, url, params,headers,data,body,responseType,withCredentials,form,forms}
      packageConfig.data=JSON.stringify(packageConfig.data)
      config = {...config, ...packageConfig}
      console.log("config",config)
      return config
    },
    function (error) {
      return Promise.reject(error)
    }
)

_axios.interceptors.response.use(
    function (response) {
      // return response.data
      return response
    },
    function (error) {
      return Promise.reject(error)
    }
)
export default _axios
